#!/bin/bash
mysql -uroot -predhat << EOF
EXIT
EOF
if [ $? -eq 0 ];then
	  echo "已经创建过"
	mysql -uroot -predhat << EOF
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'redhat' ;
EXIT
EOF
cd /usr/local/apache-tomcat-9.0.54/bin/
./startup.sh
else
mysql_secure_installation << EOF

y
redhat
redhat




EOF
mysql -uroot -predhat << EOF
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'redhat' ;
create database danyu;
EXIT
EOF
mysql -uroot -p -D danyu < /root/jeesns.sql
cd /usr/local/apache-tomcat-9.0.54/bin/
./startup.sh
fi
